/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package myetl;

import java.util.ArrayList;

/**
 *
 * @author apuangr1
 */
public class Updater {

    ArrayList<DestData> destDatas;
    String insertSql;
    String table;
    AppManager apm;
    String columns;
    String[] cols;

    Updater(AppManager apm) {

        this.apm = apm;
        this.table = this.apm.getDestTable();
        this.columns = this.apm.getDestColumns();
        cols = columns.split(",");
        for (int i = 0; i < cols.length; i++) {
            cols[i] = cols[i].trim();
//            System.out.println(cols[i]);
        }

        buildInsertStatement();

        //        retrieve();
        //        retrieve();
    }

    public void buildInsertStatement() {
        insertSql = "insert into " + table + "  (" + columns + " ) values ( ";
        for (int i = 0; i < cols.length; i++) {
            if (i == cols.length - 1) {
                insertSql = insertSql + "?)";
            } else {
                insertSql = insertSql + "?,";
            }


        }
//        System.out.println(insertSql);
    }
}
